package com.dt76.smallloanfrontenduser.controller.xiaohao;

import com.dt76.smallloanfrontenduser.pojo.xiaohao.BorrowOrder;
import com.dt76.smallloanfrontenduser.remote.xiaohao.XBorrowOrderRemote;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Controller
public class AddBorrowOrderController {

    @Resource
    private XBorrowOrderRemote xBorrowOrderRemote;

    @RequestMapping("/order/add")
    @ResponseBody
    public Boolean addOrder(BorrowOrder borrowOrder,String uId) {
        borrowOrder.setuId(Long.parseLong(uId));
        boolean flag = false;
        int i = xBorrowOrderRemote.addBorrowOrder(borrowOrder);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }

    @RequestMapping("/main/check")
    @ResponseBody
    public Map<String,Object> showBoType(String boId){
        Map<String,Object> map = new HashMap<>();
        BorrowOrder borrowOrder = xBorrowOrderRemote.qryBorrowOrderBybOID(Integer.parseInt(boId));
        System.out.println(borrowOrder.getBoType());
        map.put("boType",borrowOrder.getBoType());
        return map;
    }
}
